import { _decorator, Component, Node } from 'cc';
import { IGuideData } from './core/IGuideData';
import { GuideCommandExecutor } from './core/GuideCommandExecutor';
import { BaseMoveCommand } from './core/BaseMoveCommand';
import { ClickGuideCommand } from './core/ClickGuideCommand';
import { SwipeMoveGuideCommand } from './core/SwipeMoveGuideCommand';
import { GuideCommandFactory } from './core/GuideCommandFactory';
import { BaseGuideCommand } from './core/BaseGuideCommand';
const { ccclass, property } = _decorator;

@ccclass('GuideContext')
export class GuideContext {
    private executor: GuideCommandExecutor;

    constructor() {
        this.executor = new GuideCommandExecutor()
    }

    public runGuide(node: Node, step: IGuideData): void {
        if (step == null || node == null)
            return;
        let command: BaseGuideCommand
        switch (step.type) {
            case 1:
                command = GuideCommandFactory.create(BaseMoveCommand, node, step)
                break;
            case 2:
                command = GuideCommandFactory.create(ClickGuideCommand, node, step)
                break;
            case 3:
                command = GuideCommandFactory.create(SwipeMoveGuideCommand, node, step)
                break;
            default:
                break;
        }

        this.executor.add(command);
    }
}


